package com.taxi.service;

import com.taxi.remote.ServicePassengerUserClient;
import com.taxi.dto.PassengerUser;
import com.taxi.dto.TokenResult;
import com.taxi.result.Result;
import com.taxi.util.JwtUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: aniu
 * @Date: 2023/9/24
 * @ClassName: UserService
 * @Description: Write class functionality and purpose here.
 * @Version: 1.0
 */
@Service
@Slf4j
public class UserService {
    @Autowired
    private ServicePassengerUserClient servicePassengerUserClient;

    public Result getUserByAccessToken(String accessToken){
        log.info("accessToken:"+accessToken);
        //解析accessToken,拿到手机号
        TokenResult tokenResult = JwtUtils.checkToken(accessToken);
        String phone = tokenResult.getPhone();

        //根据手机号查询用户信息
        Result<PassengerUser> result = servicePassengerUserClient.getUserByPhone(phone);
        return result;
    }
}
